@model Orchard.Users.Models.RegistrationSettingsPart
@using Orchard.Messaging.Services;

@{
    var messageManager = WorkContext.Resolve<IMessageManager>();
    var emailEnabled = messageManager.GetAvailableChannelServices().Contains("email");
}

<fieldset>
    <legend>@T("Users")</legend>
    <div>
        @Html.EditorFor(m => m.UsersCanRegister) 
        <label class="forcheckbox" for="@Html.FieldIdFor( m => m.UsersCanRegister)">@T("Users can create new accounts on the site")</label>
    </div>
    <div>
        <input type="checkbox" value="true" class="check-box" id="@Html.FieldIdFor(m => m.EnableLostPassword)" name="@Html.FieldNameFor(m => m.EnableLostPassword)" @(Model.EnableLostPassword ? "checked=\"checked\"" : "") @(emailEnabled ? "" : "disabled=\"disabled\"")/>
        <input name="@Html.FieldNameFor(m => m.EnableLostPassword)" type="hidden" value="false">
        <label class="forcheckbox" for="@Html.FieldIdFor( m => m.EnableLostPassword)">@T("Display a link to enable users to reset their password")</label>
        
        @if(!emailEnabled) {
            <div class="message message-Warning">@T("This option is available when an email module is activated.")</div>
        }
    </div>
    <div>
        <input type="checkbox" value="true" class="check-box" id="@Html.FieldIdFor(m => m.UsersMustValidateEmail)" name="@Html.FieldNameFor(m => m.UsersMustValidateEmail)" @(Model.UsersMustValidateEmail ? "checked=\"checked\"" : "") @(emailEnabled ? "" : "disabled=\"disabled\"")/>  
        <input name="@Html.FieldNameFor(m => m.UsersMustValidateEmail)" type="hidden" value="false">
        <label class="forcheckbox" for="@Html.FieldIdFor( m => m.UsersMustValidateEmail)">@T("Users must verify their email address")</label>

        @if(!emailEnabled) {
            <div class="message message-Warning">@T("This option is available when an email module is activated.")</div>
        }
    </div>
    <div data-controllerid="@Html.FieldIdFor(m => m.UsersMustValidateEmail)">
        <label for="@Html.FieldIdFor( m => m.ValidateEmailRegisteredWebsite)">@T("Website public name")</label>
        @Html.TextBoxFor(m => m.ValidateEmailRegisteredWebsite, new { @class = "text medium" } )
        @Html.ValidationMessage("ValidateEmailRegisteredWebsite", "*")
        <span class="hint">@T("The name of your website as it will appear in the verification e-mail.")</span>
        
        <label for="@Html.FieldIdFor( m => m.ValidateEmailContactEMail)">@T("Contact Us E-Mail address")</label>
        @Html.TextBoxFor(m => m.ValidateEmailContactEMail, new { @class = "text medium" } )
        @Html.ValidationMessage("ValidateEmailContactEMail", "*")
        <span class="hint">@T("The e-mail address displayed in the verification e-mail for a Contact Us link. Leave empty for no link.")</span>
    </div>
    <div>
        @Html.EditorFor(m => m.UsersAreModerated)
        <label class="forcheckbox" for="@Html.FieldIdFor( m => m.UsersAreModerated)">@T("Users must be approved before they can log in")</label>
    </div>    
    <div data-controllerid="@Html.FieldIdFor(m => m.UsersAreModerated)">
        <input type="checkbox" value="true" class="check-box" id="@Html.FieldIdFor(m => m.NotifyModeration)" name="@Html.FieldNameFor(m => m.NotifyModeration)" @(Model.NotifyModeration ? "checked=\"checked\"" : "") @(emailEnabled ? "" : "disabled=\"disabled\"")/>
        <input name="@Html.FieldNameFor(m => m.NotifyModeration)" type="hidden" value="false">
        <label class="forcheckbox" for="@Html.FieldIdFor( m => m.NotifyModeration)">@T("Send a notification when a user needs moderation")</label>

        @if(!emailEnabled) {
            <div class="message message-Warning">@T("This option is available when an email module is activated.")</div>
        }

    </div>
    <div data-controllerid="@Html.FieldIdFor(m => m.NotifyModeration)">
        <label for="@Html.FieldIdFor( m => m.NotificationsRecipients)">@T("Moderators")</label>
        @Html.TextBoxFor(m => m.NotificationsRecipients, new { @class = "text medium" } )
        @Html.ValidationMessage("NotificationsRecipients", "*")
        <span class="hint">@T("The usernames to send the notifications to (e.g., \"admin, user1, ...\").")</span>
    </div>    
</fieldset>